from dataclasses import dataclass, field
from functools import total_ordering


@dataclass
@total_ordering
class School:
    index: int
    number: int
    team_count: int = 0
    people_count: int = 0
    full: bool = False
    num: list[int] = field(default_factory=lambda: [])

    def append_num(self, num):
        self.num.append(num)
        self.people_count += 1
        if (self.people_count % 10) == 0:
            self.people_count = 0
            self.team_count += 1
            if self.team_count == self.number:
                self.full = True

    def __iter__(self):
        for i in range(self.team_count):
            yield self.num[i * 10:(i + 1) * 10]

    def __eq__(self, other):
        return self.index == other.index

    def __lt__(self, other):
        return self.index < other.index


x = int(input())
s = map(int, input().split())
schools = [School(index, i) for index, i in enumerate(s)]
good_school = []
step = 0


def getStep():
    global step
    if len(schools) == 1:
        if step % 2 == 1:
            step += 1
            return step
        step += 2
        return step
    else:
        step += 1
        return step


while len(schools):
    for index, i in enumerate(schools):
        i.append_num(getStep())
        if i.full:
            good_school.append(i)
            del schools[index]
good_school.sort()
for index_x, i in enumerate(good_school):
    print('#' + str(i.index + 1))
    for index, j in enumerate(i):
        print(" ".join(map(str, j)))
    #     if index != i.team_count - 1:
    #         print()
    # if index_x != len(good_school) - 1:
    #     print()